package com.mdx.order.config;
import com.mdx.order.resolver.LoginManagerHandlerMethodArgumentResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * Web 应用配置类
 */
@Configuration
public class WebAppConfig implements WebMvcConfigurer, ApplicationContextAware {

    @Autowired
    LoginManagerHandlerMethodArgumentResolver loginManagerHandlerMethodArgumentResolver;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        // 添加登录用户方法参数拦截器，用于获取当前登录用户信息
        resolvers.add(loginManagerHandlerMethodArgumentResolver);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

    }
}
